#include <cstdio>
using namespace std;

int n,l,r;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	scanf("%d%d%d",&n,&l,&r);
	
	if(n - 1 - l % n <= r - l) printf("%d\n",n - 1);
	else printf("%d\n",r % n);
	
	return 0;
}
